<!DOCTYPE html>
<html>

<head>
<meta charset="UTF-8">
<title>部门勤绩考核</title>
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport"
	content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon" />
<link rel="stylesheet" href="static/css/font.css">
<link rel="stylesheet" href="static/css/xadmin.css">
<script type="text/javascript" src="static/js/jquery-3.3.1.js"></script>
<script type="text/javascript" src="static/lib/layui/layui.js"></script>
<script type="text/javascript" src="static/js/xadmin.js"></script>
	<script type="text/javascript" src="static/js/xadminEmp.js"></script>

	<style type="text/css">
		.layui-table-cell {
			height: auto;
			line-height: 20px;
			padding: 0 15px;
			position: relative;
			overflow: hidden;
			text-overflow: ellipsis;
			box-sizing: border-box;
			white-space: nowrap;   //nowrap=不换行   normal=正常
		}
	</style>
</head>

<body class="layui-anim layui-anim-up">

	<div class="x-nav">
		<span class="layui-breadcrumb"> <a>部门人员</a> <a> <cite>平时考核</cite></a>
		</span> <a class="layui-btn layui-btn-small"
			style="line-height: 1.6em; margin-top: 3px; float: right"
			href="javascript:location.replace(location.href);" title="刷新"> <i
			class="layui-icon" style="line-height: 30px">ဂ</i></a>
	</div>
	<div class="x-body" id="container">
		<div class="demoTable">
			<span style="color:#FF4500;font-size:15px">提示: 优=4;  良=3;  中=2;  差=1; </span>
			&nbsp&nbsp&nbsp
			&nbsp&nbsp&nbsp
			&nbsp&nbsp&nbsp
			&nbsp&nbsp&nbsp
			<a class="layui-btn layui-btn-danger tagDetail"><i
					class="layui-icon layui-icon-key"></i>查看标签详情</a>
		</div>
		<div style="text-align: center">
			<table id="demo" class="layui-table" lay-filter="demo"></table>
		</div>
		<!--id的隐藏域-->
        <input type="hidden" value="" id="dIdInput">
        <!--id的隐藏域-->
        <input type="hidden" value="" id="gTargetid">
        
		<div class="layui-inline">
			<a class="layui-btn layui-btn-normal batchUnlock"><i
				class="layui-icon layui-icon-key"></i>提交</a>
		</div>
	</div>
</body>
<script>
    layui.use(['laydate','table'], function(){
            var laydate = layui.laydate
            ,table = layui.table;
            
            var gTargetid =decodeURI(getQueryVariable("gTargetid"));//评价指标项目ID
            var bpjbmDId =decodeURI(getQueryVariable("dId"));//被评价部门ID
            var eAccount =decodeURI(getQueryVariable("eAccount"));//评价员工的ID

        	console.log("gTargetid=" + JSON.stringify(gTargetid));

        	var gTargetidArr = gTargetid.split(',');
			//检测是不是数组的实例
        	console.log(gTargetidArr instanceof Array);//true

            var cols = [];
            cols.push({field:'eAccount', rowspan:1, title: '工号', width:70, align: 'center',fixed: 'left'});
            cols.push({field: 'eName', rowspan:1, title: '姓名', width:100, align: 'center',fixed: 'left'});


			gTargetidArr.find(function(value) {
				if(value === "1") {//则包含该元素
                    cols.push({field:'qTargetscore1', title:'业务学习考核' , width:200, align: 'center',edit:'number'});
				}
			})
        	gTargetidArr.find(function(value) {
				if(value === "2") {//则包含该元素
                    cols.push({field:'qTargetscore2', title:'收退件理由说明' , width:150, align: 'center',edit:'number'});
				}
			})

			gTargetidArr.find(function(value) {
				if(value === "3") {//则包含该元素
					cols.push({field:'qTargetscore3', title:'许可结果公示考核' , width:150, align: 'center',edit:'number'});
				}
			})
			gTargetidArr.find(function(value) {
				if(value === "4") {//则包含该元素
                    //cols.push({field:'qTargetscore', title:'审批材料收取规范性' , width:150, align: 'center',edit:'number'});
                    cols.push({field:'qTargetscore4',title:'审批材料收取规范' , width:'10%', align: 'center',edit:'number',unresize:true});
				}
			})
			gTargetidArr.find(function(value) {
				if(value === "5") {//则包含该元素
					cols.push({field:'qTargetscore5', title:'收退件程序规范' , width:150, align: 'center',edit:'number'});
				}
			})
			gTargetidArr.find(function(value) {
				if(value === "6") {//则包含该元素
					cols.push({field:'qTargetscore6', title:'处理与回复情况' , width:150, align: 'center',edit:'number'});
				}
			})
			gTargetidArr.find(function(value) {
				if(value === "7") {//则包含该元素
					cols.push({field:'qTargetscore7', title:'12345处理回复情况' , width:150, align: 'center',edit:'number'});
				}
			})
			gTargetidArr.find(function(value) {
				if(value === "8") {//则包含该元素
					cols.push({field:'qTargetscore8', title:'审批环节与办理实效' , width:300, align: 'center',edit:'number'});
				}
			})
			gTargetidArr.find(function(value) {
				if(value === "9") {//则包含该元素
					cols.push({field:'qTargetscore9', title:'群众满意度调查' , width:150, align: 'center',edit:'number'});
				}
			})
			gTargetidArr.find(function(value) {
				if(value === "10") {//则包含该元素
					cols.push({field:'qTargetscore10', title:'好差评考核' , width:150, align: 'center',edit:'number'});
				}
			})
			gTargetidArr.find(function(value) {
				if(value === "11") {//则包含该元素
					cols.push({field:'qTargetscore11', title:'投诉举报情况' , width:150, align: 'center',edit:'number'});
				}
			})
			gTargetidArr.find(function(value) {
				if(value === "12") {//则包含该元素
					cols.push({field:'qTargetscore12', title:'业务学习考核' , width:150, align: 'center',edit:'number'});
				}
			})
			gTargetidArr.find(function(value) {
				if(value === "13") {//则包含该元素
					cols.push({field:'qTargetscore13', title:'服务行为规范考核' , width:150, align: 'center',edit:'number'});
				}
			})
			gTargetidArr.find(function(value) {
				if(value === "14") {//则包含该元素
					cols.push({field:'qTargetscore14', title:'恶性事件考核' , width:150, align: 'center',edit:'number'});
				}
			})
			gTargetidArr.find(function(value) {
				if(value === "15") {//则包含该元素
					cols.push({field:'qTargetscore15', title:'上班行为考核' , width:150, align: 'center',edit:'number'});
				}
			})
			gTargetidArr.find(function(value) {
				if(value === "16") {//则包含该元素
					cols.push({field:'qTargetscore16', title:'通报批评情况' , width:150, align: 'center',edit:'number'});
				}
			})
			gTargetidArr.find(function(value) {
				if(value === "17") {//则包含该元素
					cols.push({field:'qTargetscore17', title:'窗口环境考核' , width:150, align: 'center',edit:'number'});
				}
			})
			gTargetidArr.find(function(value) {
				if(value === "18") {//则包含该元素
					cols.push({field:'qTargetscore18', title:'窗口到岗情况考核' , width:150, align: 'center',edit:'number'});
				}
			})
			gTargetidArr.find(function(value) {
				if(value === "19") {//则包含该元素
					cols.push({field:'qTargetscore19', title:'计算机和网络事故情况' , width:150, align: 'center',edit:'number'});
				}
			})
			gTargetidArr.find(function(value) {
				if(value === "20") {//则包含该元素
					cols.push({field:'qTargetscore20', title:'群众满意度考核' , width:150, align: 'center',edit:'number'});
				}
			})
			gTargetidArr.find(function(value) {
				if(value === "21") {//则包含该元素
					cols.push({field:'qTargetscore21', title:'好差评考核' , width:150, align: 'center',edit:'number'});
				}
			})
            gTargetidArr.find(function(value) {
                if(value === "22") {//则包含该元素
                    cols.push({field:'qTargetscore22', title:'投诉举报情况' , width:150, align: 'center',edit:'number'});
                }
            })
          //第一个实例
         table.render({
             elem: '#demo'
            ,height: 'full'
            ,url: 'empDepartmentScore/findDempSelective.do?bpjbmDId='+bpjbmDId+'&qTargetid='+gTargetid
            ,page: false
            ,initSort: {field: 'eAccount', type: 'desc'}
            ,id:'demo'
            ,cols: [cols]
         });
          
        var $ = layui.$, active = {
            reload: function () {
                var demoReload = $('#demoReload');
                //执行重载
                console.log(demoReload);
                table.reload('demo', {
                    where: {
                        e_id: $("#e_id").val()
                    }
                });
            }
        };
        $('.demoTable .layui-btn').on('click', function () {
            var type = $(this).data('type');
            console.log(type);
            active[type] ? active[type].call(this) : '';
        });
        
        //批量提交  使用封装后的ajax
        $(".batchUnlock").click(function (){
            const list = table.cache['demo'];

            checkInputRemoveVariable(list,gTargetid);
            /**
            var flag = checkInputVariable(list,gTargetid);
            if(flag){
            	return layer.msg("请您核实,分数请输入不为空的整数!");
            }
			 **/
            console.log("list1111=" + JSON.stringify(list));
            //console.log("qTargetid="+gTargetid);
            $.ajax({
                type: 'post',
                url: 'empDepartmentScore/updateDepGrand.do',
                data: "list="+JSON.stringify(list)+'&qTargetid='+gTargetid+'&dId='+bpjbmDId,
                dataType: 'json',
                success: function (result) {
                	if(result.code==0){
                		layer.msg(result.msg);
                		//关闭当前页面
                		layer.alert(result.msg, {title: "添加信息"},
                                 function () {
                                     window.parent.location.reload();
                                     var index = parent.layer.getFrameIndex(window.name);
                                     parent.layer.close(index);
                                 }
                             )
                		
                	}else{
                		layer.msg(result.msg);
                	}
                }
            });
           
        });



        $(".tagDetail").click(function (){
            xx_admin_show('指标详情描述',
                'toPage.do?url=employee/employeeDepTagDetail.html?gTargetid='+gTargetid
                , 1200,500);
        });


    });
    //考核输入项检查
    function checkInputVariable(list,gTargetid)
	{

        console.log("list222=" + JSON.stringify(list));
        console.log("gTargetid=" + JSON.stringify(gTargetid));

	    var len = list.length;
        for(var i=0; i<len; i++){
        	
        	var value = list[i].qTargetscore1;
    		if(typeof (value) == 'undefined'){
    			return true;
    		}else{
    			if(value == ''){
    				return true;
    			}else{
    				var regPos = /^\d+(\.\d+)?$/; //非负浮点数
                    var regNeg = /^(-(([0-9]+\.[0-9]*[1-9][0-9]*)|([0-9]*[1-9][0-9]*\.[0-9]+)|([0-9]*[1-9][0-9]*)))$/; //负浮点数
                    if((!regPos.test(value)) && !regNeg.test(value) && !value.match("[1-9]+")){
                    	return true;
                    }
    			}
    		}
        	delete list[i].LAY_TABLE_INDEX;
    	}
	}

    //删除无用项
    function checkInputRemoveVariable(list,gTargetid)
    {

        console.log("list222=" + JSON.stringify(list));
        console.log("gTargetid=" + JSON.stringify(gTargetid));

        var len = list.length;
        for(var i=0; i<len; i++){
            delete list[i].LAY_TABLE_INDEX;
        }
    }
    
  	//获取父页面请求url传过来的参数
	function getQueryVariable(variable)
	{
	    var query = window.location.search.substring(1);
	    var index = query.indexOf("?");
	    query = query.substr(index+1,query.length);
	    var vars = query.split("&");
	    for (var i=0;i<vars.length;i++) {
	        var pair = vars[i].split("=");
	        if(pair[0] == variable){
	        	console.log(pair[1]);
	            return pair[1];
	        }
	    }
	    return false;
	}
</script>
</html>
